using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using TextEditor.Actions;

namespace EditeurSyntaxiqueVocal.Languages.LanguageZ
{
    public partial class ZToPascal : Form
    {
        public ZToPascal(string textZ)
        {
            InitializeComponent();
            editeurTextZ.Document.TextContent = textZ;
            editeurTextZ.SetHighlighting("Z");
            editeurTextPascal.SetHighlighting("Pascal");
            editeurTextZ.ActiveTextAreaControl.TextArea.Document.ReadOnly = true;
        }

        private void nouveauToolStripButton_Click(object sender, EventArgs e)
        {

        }

        private void ouvrirToolStripButton_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    TextReader textReader = new StreamReader(openFileDialog1.FileName);
                    editeurTextPascal.ActiveTextAreaControl.TextArea.Document.TextContent = textReader.ReadToEnd();
                    textReader.Close();
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                }
            }
        }

        private void enregistrerToolStripButton_Click(object sender, EventArgs e)
        {
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    TextWriter textWriter = new StreamWriter(saveFileDialog1.FileName);
                    textWriter.Write(editeurTextPascal.ActiveTextAreaControl.TextArea.Document.TextContent);
                    textWriter.Close();
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                }
            }
        }

        private void imprimerToolStripButton_Click(object sender, EventArgs e)
        {
            PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog();
            printPreviewDialog1.Document = editeurTextPascal.PrintDocument;
            printPreviewDialog1.TopMost = true;
            printPreviewDialog1.Owner = this;
            printPreviewDialog1.Show();
        }

        private void couperToolStripButton_Click(object sender, EventArgs e)
        {
            new Cut().Execute(editeurTextPascal.ActiveTextAreaControl.TextArea);
        }

        private void copierToolStripButton_Click(object sender, EventArgs e)
        {
            new Copy().Execute(editeurTextPascal.ActiveTextAreaControl.TextArea);
        }

        private void collerToolStripButton_Click(object sender, EventArgs e)
        {
            new Paste().Execute(editeurTextPascal.ActiveTextAreaControl.TextArea);
        }

        private void ToolStripButton_Click(object sender, EventArgs e)
        {
            Process.Start(@".\Languages\LanguageZ\kwz\editeur\aide_langz.HLP");
        }
    }
}